# 原有的数组上的数字变为0即可

class Solution:

    def productExecptSelf(self, nums: list[int]) -> list[int]:

        ans, tmp = [1] * len(nums), 1

        for i in range(1, len(nums)):

            ans[i] = ans[i - 1] * nums[i - 1]

        for i in range(len(nums) - 2, -1, -1):
            
            tmp = tmp * nums[i + 1]
            ans[i] = ans[i] * tmp

    
        return ans
    


if __name__ == "__main__":

    nums = [1, 2, 3, 4]

    sol = Solution()
    ans = sol.productExecptSelf(nums=nums)

    print(ans)

